package com.ymatou.iapi.settlement.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.json.JSONArray;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.settlement.parameter.OrderSettlementReq;
import com.ymatou.iapi.settlement.service.GenerateInvoicesOnOrderReceivedCall;
import com.ymatou.iapi.settlement.service.SettlementService;
import com.ymatou.iapi.trading.operate.parameter.ActivityVo;
import com.ymatou.iapi.trading.operate.parameter.Order;
import com.ymatou.iapi.trading.operate.parameter.OrderGroupVo;
import com.ymatou.iapi.trading.operate.parameter.OrderInfoPo;
import com.ymatou.iapi.trading.operate.parameter.OrderItemVo;
import com.ymatou.iapi.trading.operate.parameter.OrderVo;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderService;
import com.ymatou.iapi.trading.operate.parameter.SellerCouponVo;
import com.ymatou.iapi.trading.operate.parameter.YmatouCouponVo;
import com.ymatou.iapi.trading.operate.parameter.enums.ActivityPromotionTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.AppTerminalSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.LogisticsTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.OrderSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.OrderTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.PriceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.ProductRefundChannelEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.SalesTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.SellerCouponApplianceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.TerminalSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.YmatouCouponApplianceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.req.ApplySalesRefundRequestBean;
import com.ymatou.iapi.trading.operate.parameter.req.PlaceOrderReq;
import com.ymatou.iapi.trading.operate.service.PlaceOrderCall;
import com.ymatou.operate.trading.api.service.ApplySalesRefundRequestCall;
import com.ymt.base.YmatouEasyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.CouponCallService;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.business.service.ProductCallService;
import com.ymttest.business.service.UserCallService;
import com.ymttest.database.model.YmtCommissionDetail;
import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.database.sqlwapper.YmtCommissionDetailWapper;
import com.ymttest.database.sqlwapper.YmtRefundWapper;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

/**
 * 确认收货生成确认收货，佣金结算单FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GenerateInvoicesOnOrderReceived {
	private static OrderSettlementReq generateinvoicesonorderreceivedBean;
	private static GenerateInvoicesOnOrderReceivedCall generateinvoicesonorderreceivedCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("确认收货时生成结算单接口");
	}

	@Before
	public void caseUp() {
		generateinvoicesonorderreceivedBean = new OrderSettlementReq();
		generateinvoicesonorderreceivedCall = new GenerateInvoicesOnOrderReceivedCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(generateinvoicesonorderreceivedCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	public static BigDecimal calcRealPayAmountOnProduct(String orderInfoId) {
		BigDecimal payAmount = BigDecimal.ZERO;
		DefaultWapper defaultWapper = new DefaultWapper();

		List<Map> ymtOrderInfoList = defaultWapper
				.selectOrderInfoByOrderInfoId(orderInfoId);

		BigDecimal fProductPrice = (BigDecimal) ymtOrderInfoList.get(0).get(
				"fProductPrice");
		int iAmount = (Integer) ymtOrderInfoList.get(0).get("iAmount");
		BigDecimal fDiscount = (BigDecimal) ymtOrderInfoList.get(0).get(
				"fDiscount");
		BigDecimal fFreight = (BigDecimal) ymtOrderInfoList.get(0).get(
				"fFreight");
		BigDecimal fSellerPromotionAmount = (BigDecimal) ymtOrderInfoList
				.get(0).get("fSellerPromotionAmount");
		BigDecimal fSellerCouponAmount = (BigDecimal) ymtOrderInfoList.get(0)
				.get("fSellerCouponAmount");
		//新需求，计算用户 加上平台券金额 add 9.18
		BigDecimal fYmtCouponAmount = (BigDecimal) ymtOrderInfoList.get(0).get(
				"fYmtCouponAmount");

		payAmount = fProductPrice.multiply(new BigDecimal(iAmount))
				.add(fDiscount).add(fFreight).subtract(fSellerPromotionAmount)
				.subtract(fSellerCouponAmount);

		return payAmount;
	}

	private void verifyDb() {

		int orderId = generateinvoicesonorderreceivedBean.getOrderId();
		try {

			Thread.sleep(3000);

			DefaultWapper defaultWapper = new DefaultWapper();
			OrderCallService orderCallService = new OrderCallService();

			// 订单主表
			List<Map> ymtOrders = defaultWapper.selectOrderByOderId(orderId);

			// 退款退货表
			YmtRefundWapper ymtRefund = new YmtRefundWapper();

			int sellerId = (Integer) ymtOrders.get(0).get("iBuyerId");
			// 佣金
			List<YmtCommissionDetail> ymtCommissionDetailList = new YmtCommissionDetailWapper()
					.selectByOrderId(orderId);

			// 结算佣金
			List<YmtCommissionDetail> ymtSettlemCommissionDetailList = ymtCommissionDetailList
					.stream()
					.filter(commission -> commission.getInvoiceType() == 4)
					.collect(Collectors.toList());

			// 返还佣金
			List<YmtCommissionDetail> ymtBackCommissionDetailList = ymtCommissionDetailList
					.stream()
					.filter(commission -> commission.getInvoiceType() == 6)
					.collect(Collectors.toList());

			// // 订单退款平台券
			BigDecimal productRefundSettlementAmountOfCoupon = BigDecimal.ZERO;

			//	订单总的退运费
			BigDecimal orderRefundedAmountOfFreight = BigDecimal.ZERO;

			// 结算佣金
			for (YmtCommissionDetail ymtCommissionDetail : ymtSettlemCommissionDetailList) {

				Logger.comment("校验Ymt_CommissionDetail表");

				Logger.comment("校验商品id:" + ymtCommissionDetail.getProductId());;

				String orderInfoId = ymtCommissionDetail.getOrderInfoId();

				// 订单商品表
				List<Map> ymtOrderInfoList = defaultWapper
						.selectOrderInfoByOrderInfoId(orderInfoId);
				// 商品实际购买数量
				int iAmount = (Integer) ymtOrderInfoList.get(0).get("iAmount");

				// 商品实际付款金额
				BigDecimal proRealPayAmount = calcRealPayAmountOnProduct(orderInfoId);

				// 退货退款
				Map m = new HashMap();
				m.put("orderId", orderId);
				m.put("orderInfoId", orderInfoId);

				// 退款信息表
				List<Map> ymtRefundList = ymtRefund.selectRefundInfo(m);

				// 商品结算佣金数量
				int productCommissAmount = iAmount;
				// 商品结算佣金金额
				BigDecimal productRealPayAmount = proRealPayAmount;

				if (ymtRefundList.size() > 0) {
					// 商品退款金额
					BigDecimal productRefundSettlementAmount = (BigDecimal) ymtRefundList
							.get(0).get("SettlementAmount");
					// 商品退款平台券
					productRefundSettlementAmountOfCoupon = (BigDecimal) ymtRefundList
							.get(0).get("SettlementAmountOfCoupon");

					// 商品申请退款的运费
					BigDecimal productRefundedAmountOfFreight = (BigDecimal) ymtRefundList
							.get(0).get("RefundedAmountOfFreight");

					orderRefundedAmountOfFreight = orderRefundedAmountOfFreight
							.add(productRefundedAmountOfFreight);

					// 商品退款数量
					int productRefundProductNum = (Integer) ymtRefundList
							.get(0).get("RefundProductNum");

					// 计算商品实际算拥的支付金额 实际支付-退款
					productRealPayAmount = proRealPayAmount.subtract(
							productRefundSettlementAmount).compareTo(
							BigDecimal.ZERO) < 1
							? BigDecimal.ZERO
							: proRealPayAmount
									.subtract(productRefundSettlementAmount);

					// 商品计算佣金数量， 实际支付数量-退款数量
					productCommissAmount = (iAmount - productRefundProductNum) < 0
							? 0
							: (iAmount - productRefundProductNum);

					//add 0616 
					if ((productCommissAmount == 0)
							&& (productRealPayAmount.compareTo(BigDecimal.ZERO) > 0)) {

						productCommissAmount = 1;
					}

				}
				BigDecimal singleProRealPay;
				// 单个商品实际算佣金额
				if (productCommissAmount == 0) {
					singleProRealPay = BigDecimal.ZERO.setScale(2);
				} else {
					singleProRealPay = productRealPayAmount.divide(
							new BigDecimal(productCommissAmount), 2,
							BigDecimal.ROUND_HALF_UP);
				}
				// 结算佣金商品的数量
				Logger.verifyEquals(productCommissAmount,
						ymtCommissionDetail.getProdNumOfCommission(),
						"验证ProdNumOfCommission");
				// 结算佣金单价的计算价格
				Logger.verifyEquals(singleProRealPay,
						ymtCommissionDetail.getRealPayAmountPerProd(),
						"验证RealPayAmountPerProd");

				// 单件商品佣金费率
				// 设置的单件商品最多佣金收费
				BigDecimal singleCommissionMax = ymtCommissionDetail
						.getSingleCommissionMax();
				// 设置的单件商品最少佣金收费
				BigDecimal singleCommissionMin = ymtCommissionDetail
						.getSingleCommissionMin();

				// 按比例计算出实际佣金收费
				BigDecimal singleCommission = ymtCommissionDetail
						.getRealPayAmountPerProd()
						.multiply(ymtCommissionDetail.getSingleCommissionRate())
						.divide(BigDecimal.ONE, 2, BigDecimal.ROUND_HALF_UP);

				if (singleCommission.compareTo(BigDecimal.ZERO) > 0) {

					/*
					 * 金额1=每件商品实际支付金额×商品佣金比例 金额2=max（金额1，单件商品收佣下限金额） 每件商品交易佣金=min（金额2，单件商品收佣上限金额）
					 */

					if (singleCommissionMin.compareTo(BigDecimal.ZERO) > 0) {
						if (singleCommission.compareTo(singleCommissionMin) > 0)
							singleCommission = singleCommission;
						else
							singleCommission = singleCommissionMin;
					}

					if (singleCommissionMax.compareTo(BigDecimal.ZERO) > 0) {
						if (singleCommission.compareTo(singleCommissionMax) > 0)
							singleCommission = singleCommissionMax;
					}
				}

				Logger.verifyEquals(singleCommission,
						ymtCommissionDetail.getCommissionPerProd(),
						"验证CommissionPerProd");

				// 单件商品佣金费率*结算数量
				Logger.verifyEquals(ymtCommissionDetail.getCommissionPerProd()
						.multiply(new BigDecimal(productCommissAmount))
						.setScale(2),
						ymtCommissionDetail.getCommissionAmount(),
						"验证CommissionAmount");
			}

			// 计算订单下所有商品佣金总和
			BigDecimal orderCommissionAmount = ymtSettlemCommissionDetailList
					.stream().map(m -> m.getCommissionAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			// 计算订单下所有运费总和
			BigDecimal orderRealPayFreight = ymtSettlemCommissionDetailList
					.stream().map(m -> m.getRealPayFreight())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			// 查询交易退款结算表
			List<Map> settlementInvoiceList = defaultWapper
					.selectYmtSettlementInvoice(orderId);
			// 查询用户下单结算的金额
			BigDecimal settlementAmout = orderCallService
					.getReceiveAmountOfCash(orderId);
			// 订单使用平台券金额
			BigDecimal ymtCouponAmount = (BigDecimal) ymtOrders.get(0).get(
					"fYmtCouponAmount");
			// 订单总运费金额
			BigDecimal orderfFreight = (BigDecimal) ymtOrders.get(0).get(
					"fFreight");

			DataUtil.verifyDecimalEquals(
					orderfFreight.subtract(orderRefundedAmountOfFreight),
					orderRealPayFreight, "验证结算佣金表实际结算的运费金额");

			Logger.verifyEquals(true, settlementInvoiceList.size() >= 2,
					"验证结算表数据");

			for (Map settlement : settlementInvoiceList) {
				// 确认收货收单
				if ((Integer) settlement.get("BusinessType") == 1) {
					Logger.comment("校验Ymt_SettlementInvoice表，下单确认收货结算");
					Logger.verifyEquals(String.valueOf(orderId),
							(String) settlement.get("BusinessNo"),
							"验证BusinessNo");
					Logger.verifyEquals(1,
							(Integer) settlement.get("BusinessType"),
							"验证BusinessType");
					Logger.verifyEquals(orderId,
							(Integer) settlement.get("OrderId"), "验证OrderId");
					Logger.verifyEquals(((BigDecimal) settlement
							.get("CashAmount")).add((BigDecimal) settlement
							.get("CouponAmount")), (BigDecimal) settlement
							.get("TotalAmount"), "验证TotalAmount");
					Logger.verifyEquals(settlementAmout,
							(BigDecimal) settlement.get("CashAmount"),
							"验证CashAmount");
					Logger.verifyEquals(ymtCouponAmount
							.subtract(productRefundSettlementAmountOfCoupon),
							(BigDecimal) settlement.get("CouponAmount"),
							"验证CouponAmount");
					Logger.verifyEquals(sellerId,
							(Integer) settlement.get("SellerId"), "验证SellerId");
					Logger.verifyEquals("确认收货订单结算",
							(String) settlement.get("Remark"), "验证Remark");
					Logger.verifyEquals(0,
							(Integer) settlement.get("SettlementStatus"),
							"验证SettlementStatus");
					Logger.verifyEquals(2,
							(Integer) settlement.get("SettlementUser"),
							"验证SettlementUser");
					Logger.verifyEquals(null,
							(String) settlement.get("ProcessResult"),
							"验证ProcessResult");
					Logger.verifyEquals(null,
							(BigDecimal) settlement.get("fAccountAmount"),
							"验证fAccountAmount");
					Logger.verifyEquals(null,
							(BigDecimal) settlement.get("fThirdPartyAmount"),
							"验证fThirdPartyAmount");
				}
				// 佣金结算
				if ((Integer) settlement.get("BusinessType") == 4) {
					Logger.comment("校验Ymt_SettlementInvoice表，下单确认收货佣金结算");
					Logger.verifyEquals(String.valueOf(orderId),
							(String) settlement.get("BusinessNo"),
							"验证BusinessNo");
					Logger.verifyEquals(4,
							(Integer) settlement.get("BusinessType"),
							"验证BusinessType");
					Logger.verifyEquals(orderId,
							(Integer) settlement.get("OrderId"), "验证OrderId");
					Logger.verifyEquals(((BigDecimal) settlement
							.get("CashAmount")).add((BigDecimal) settlement
							.get("CouponAmount")), (BigDecimal) settlement
							.get("TotalAmount"), "验证TotalAmount");
					Logger.verifyEquals(orderCommissionAmount,
							(BigDecimal) settlement.get("CashAmount"),
							"验证CashAmount");
					// 退的ymt 平台优惠券
					Logger.verifyEquals(BigDecimal.ZERO.setScale(2),
							(BigDecimal) settlement.get("CouponAmount"),
							"验证CouponAmount");
					Logger.verifyEquals(sellerId,
							(Integer) settlement.get("SellerId"), "验证SellerId");
					Logger.verifyEquals("收取交易服务费结算",
							(String) settlement.get("Remark"), "验证Remark");
					Logger.verifyEquals(0,
							(Integer) settlement.get("SettlementStatus"),
							"验证SettlementStatus");
					Logger.verifyEquals(2,
							(Integer) settlement.get("SettlementUser"),
							"验证SettlementUser");
					Logger.verifyEquals(null,
							(String) settlement.get("ProcessResult"),
							"验证ProcessResult");
					Logger.verifyEquals(null,
							(BigDecimal) settlement.get("fAccountAmount"),
							"验证fAccountAmount");
					Logger.verifyEquals(null,
							(BigDecimal) settlement.get("fThirdPartyAmount"),
							"验证fThirdPartyAmount");
				}
			}
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GenerateInvoicesOnOrderReceived_001() {
		Logger.start(true, "使用平台券,商家券。确认收货，校验生成下单结算单，佣金结算单 2种结算单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService.placeOrder2(true);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);

			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);

			// 不用主动调用,走消息总线
			/*			generateinvoicesonorderreceivedCall.callService();

						Logger.verifyEquals("ok",
								generateinvoicesonorderreceivedCall.getReturnData(),
								"验证返回报文");*/

			verifyDb();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_GenerateInvoicesOnOrderReceived_002() {
		Logger.start(true, "含有补贴商品的的订单,确认收货后,校验生成订单结算单,补贴商品结算单,佣金结算 3钟结算单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			Map map = placeOrder2();
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			int orderId = (Integer) map.get("orderId");
			int tradingId = (Integer) map.get("tradingId");
			int sellerId = (Integer) map.get("sellerId");
			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCash(orderId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");

			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			DefaultWapper defaultWapper = new DefaultWapper();
			// 订单商品表
			List<Map> ymtOrderinfoList = defaultWapper
					.selectOrderInfoByOderId(orderId);
			// 补贴结算
			List<Map> subsidySettlementList = defaultWapper
					.selectSubsidySettlementInvoiceByOrderId(orderId);

			BigDecimal orderSubsidyAmount = ymtOrderinfoList.stream()
					.map(m -> (BigDecimal) m.get("fSubsidyAmount"))
					.reduce(BigDecimal.ZERO, BigDecimal::add);
			Logger.comment("校验Ymt_SubsidySettlementInvoice表");
			Logger.verifyEquals(String.valueOf(orderId),
					(String) subsidySettlementList.get(0).get("BusinessNo"),
					"验证BusinessNo");
			Logger.verifyEquals(orderId, (Integer) subsidySettlementList.get(0)
					.get("OrderId"), "验证OrderId");
			Logger.verifyEquals(
					orderSubsidyAmount,
					(BigDecimal) subsidySettlementList.get(0).get(
							"SubsidyAmount"), "验证SubsidyAmount");
			Logger.verifyEquals(
					0,
					(Integer) subsidySettlementList.get(0).get(
							"SettlementStatus"), "验证SettlementStatus");
			Logger.verifyEquals(sellerId, (Integer) subsidySettlementList
					.get(0).get("SellerId"), "验证SellerId");
			Logger.verifyEquals("订单补贴", (String) subsidySettlementList.get(0)
					.get("Remark"), "验证Remark");
			verifyDb();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GenerateInvoicesOnOrderReceived_003() {
		Logger.start(true, "订单里一个商品全款退款,确认收货后,校验生成订单结算单佣金结算单");
		try {
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService.placeOrder2(true);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 退款
			orderCallService.salesRefundSuccessRequestInJava(orderId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GenerateInvoicesOnOrderReceived_004() {

		Logger.start(true, "订单里一个商品部分退款,确认收货后,校验生成订单结算单佣金结算单");

		try {
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService.placeOrder2(true);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			// 申请部分退款
			BigDecimal applyRefundAmout = new BigDecimal(130);

			ApplySalesRefundRequestBean applysalesrefundrequestBean = orderCallService
					.applySalesRefundRequestInJavaBean(orderId);
			applysalesrefundrequestBean.getSalesRefundInfoList().get(0)
					.setRefundAmount(applyRefundAmout);
			ApplySalesRefundRequestCall applysalesrefundrequestCall = new ApplySalesRefundRequestCall();
			applysalesrefundrequestCall.setData(false,
					applysalesrefundrequestBean);
			applysalesrefundrequestCall.callService();

			// 退款处理
			orderCallService
					.salesrefundsuccessrequest(applysalesrefundrequestBean);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");

			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GenerateInvoicesOnOrderReceived_005() {
		Logger.start(true, "订单里一个商品部分退款,退款数量小于商品购买数量,确认收货后,校验生成订单结算单佣金结算单");
		try {

			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService.placeOrder2(true);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			// 申请部分退款
			BigDecimal applyRefundAmout = new BigDecimal(130);
			ApplySalesRefundRequestBean applysalesrefundrequestBean = orderCallService
					.applySalesRefundRequestInJavaBean(orderId);
			applysalesrefundrequestBean.getSalesRefundInfoList().get(0)
					.setRefundAmount(applyRefundAmout);
			applysalesrefundrequestBean.getSalesRefundInfoList().get(0)
					.setRefundProductNum(1);
			ApplySalesRefundRequestCall applysalesrefundrequestCall = new ApplySalesRefundRequestCall();
			applysalesrefundrequestCall.setData(false,
					applysalesrefundrequestBean);
			applysalesrefundrequestCall.callService();
			// 退款处理
			orderCallService
					.salesrefundsuccessrequest(applysalesrefundrequestBean);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GenerateInvoicesOnOrderReceived_006() {
		Logger.start(false, "订单号为空");
		try {
			Logger.comment("前置数据准备结束");
			// generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			generateinvoicesonorderreceivedCall.callService();
			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	/**
	 * 返佣规则
	 * 新买手（审核通过之日的时间在60天以内），新客，老客全部返佣金（先收，后返）
	 * 老买手，老客  返还佣金
	 * 老买手，新用户  不返还佣金
	 */

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GenerateInvoicesOnOrderReceived_007() {
		Logger.start(true, "老买手老客户，使用平台券,商家券。确认收货，校验生成下单结算单,佣金结算，佣金返回 3种结算单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = placeOrder4();

			int userId = placeOrderResp.getUserId();
			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			OrderCallService orderCallService = new OrderCallService();

			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCash(orderId);

			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			YmatouEasyCall payPayMqSenderCall = new YmatouEasyCall("", "POST",
					"JSON");
			String payPayMqSenderString = "{\"orderId\":" + orderId + "}";
			payPayMqSenderCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/trading/onOrderPaid");
			payPayMqSenderCall.setData(payPayMqSenderString);
			Logger.comment("支付发送消息");
			payPayMqSenderCall.callService();
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Thread.sleep(5000);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);

			verifyDb();

			// 查询交易退款结算表
			List<Map> settlementInvoiceList = new DefaultWapper()
					.selectYmtSettlementInvoice(orderId);

			// 结算佣金
			List<Map> ymtSettlemCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 4)
					.collect(Collectors.toList());
			// 返还佣金
			List<Map> ymtBackCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 6)
					.collect(Collectors.toList());

			BigDecimal settlemt1 = (BigDecimal) ymtSettlemCommissionDetailList
					.get(0).get("TotalAmount");

			BigDecimal settlemt2 = (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("TotalAmount");

			Logger.comment("校验Ymt_SettlementInvoice表，下单确认收货返佣结算");
			Logger.verifyEquals(
					String.valueOf(orderId),
					(String) ymtBackCommissionDetailList.get(0).get(
							"BusinessNo"), "验证BusinessNo");
			Logger.verifyEquals(orderId, (Integer) ymtBackCommissionDetailList
					.get(0).get("OrderId"), "验证OrderId");
			Logger.verifyEquals(settlemt1, settlemt2, "验证老买手老客户，全部返回佣金");
			Logger.verifyEquals(
					((BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CashAmount"))
							.add((BigDecimal) ymtBackCommissionDetailList
									.get(0).get("CouponAmount")),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"TotalAmount"), "验证TotalAmount");
			Logger.verifyEquals(
					BigDecimal.ZERO.setScale(2),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CouponAmount"), "验证CouponAmount");
			Logger.verifyEquals(sellerId, (Integer) ymtBackCommissionDetailList
					.get(0).get("SellerId"), "验证SellerId");
			Logger.verifyEquals("返还交易服务费结算",
					(String) ymtBackCommissionDetailList.get(0).get("Remark"),
					"验证Remark");
			Logger.verifyEquals(0, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementStatus"), "验证SettlementStatus");
			Logger.verifyEquals(2, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementUser"), "验证SettlementUser");
			Logger.verifyEquals(
					null,
					(String) ymtBackCommissionDetailList.get(0).get(
							"ProcessResult"), "验证ProcessResult");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fAccountAmount"), "验证fAccountAmount");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fThirdPartyAmount"), "验证fThirdPartyAmount");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	// @Ignore
	//
	// 手工修改买手审批时间在60天内买手
	// select top 10 dateadd(day,-59,GETDATE()) from ymt_sellerinfo where iuserid=20224977
	// update ymt_sellerinfo set ApproveTime='2016-05-31 19:16:40.337' where iuserid=20224977
	public void Tc_GenerateInvoicesOnOrderReceived_008() {
		Logger.start(true, "60天内通过审核的新买手，老客户，使用平台券,商家券。"
				+ "确认收货，校验生成下单结算单,佣金结算，佣金返回 3种结算单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			Map map = placeOrder3();

			int userId = (Integer) map.get("userId");
			int sellerId = (Integer) map.get("sellerId");
			JSONArray orderIds = (JSONArray) map.get("orderIds");
			int tradingId = (Integer) map.get("tradingId");
			int orderId = orderIds.getInt(0);
			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCash(orderId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			YmatouEasyCall payPayMqSenderCall = new YmatouEasyCall("", "POST",
					"JSON");
			String payPayMqSenderString = "{\"orderId\":" + orderId + "}";
			payPayMqSenderCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/trading/onOrderPaid");
			payPayMqSenderCall.setData(payPayMqSenderString);
			Logger.comment("支付发送消息");
			payPayMqSenderCall.callService();
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Thread.sleep(5000);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();

			// 查询交易退款结算表
			List<Map> settlementInvoiceList = new DefaultWapper()
					.selectYmtSettlementInvoice(orderId);

			// 结算佣金
			List<Map> ymtSettlemCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 4)
					.collect(Collectors.toList());
			// 返还佣金
			List<Map> ymtBackCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 6)
					.collect(Collectors.toList());

			BigDecimal settlemt1 = (BigDecimal) ymtSettlemCommissionDetailList
					.get(0).get("TotalAmount");

			BigDecimal settlemt2 = (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("TotalAmount");

			Logger.comment("校验Ymt_SettlementInvoice表，下单确认收货返佣结算");
			Logger.verifyEquals(
					String.valueOf(orderId),
					(String) ymtBackCommissionDetailList.get(0).get(
							"BusinessNo"), "验证BusinessNo");
			Logger.verifyEquals(orderId, (Integer) ymtBackCommissionDetailList
					.get(0).get("OrderId"), "验证OrderId");
			Logger.verifyEquals(settlemt1, settlemt2, "验证新买手，全部返回佣金");
			Logger.verifyEquals(
					((BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CashAmount"))
							.add((BigDecimal) ymtBackCommissionDetailList
									.get(0).get("CouponAmount")),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"TotalAmount"), "验证TotalAmount");
			Logger.verifyEquals(
					BigDecimal.ZERO.setScale(2),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CouponAmount"), "验证CouponAmount");
			Logger.verifyEquals(sellerId, (Integer) ymtBackCommissionDetailList
					.get(0).get("SellerId"), "验证SellerId");
			Logger.verifyEquals("返还交易服务费结算",
					(String) ymtBackCommissionDetailList.get(0).get("Remark"),
					"验证Remark");
			Logger.verifyEquals(0, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementStatus"), "验证SettlementStatus");
			Logger.verifyEquals(2, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementUser"), "验证SettlementUser");
			Logger.verifyEquals(
					null,
					(String) ymtBackCommissionDetailList.get(0).get(
							"ProcessResult"), "验证ProcessResult");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fAccountAmount"), "验证fAccountAmount");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fThirdPartyAmount"), "验证fThirdPartyAmount");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	// @Ignore
	//
	// 手工修改买手审批时间在60天内买手
	// select top 10 dateadd(day,-59,GETDATE()) from ymt_sellerinfo where iuserid=20224977
	// update ymt_sellerinfo set ApproveTime='2016-05-31 19:16:40.337' where iuserid=20224977
	public void Tc_GenerateInvoicesOnOrderReceived_009() {
		Logger.start(true, "60天内通过审核的新买手，新客户，使用平台券,商家券。"
				+ "确认收货，校验生成下单结算单,佣金结算，佣金返回 3种结算单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			Map map = placeOrder7();
			int userId = (Integer) map.get("userId");
			int sellerId = (Integer) map.get("sellerId");
			JSONArray orderIds = (JSONArray) map.get("orderIds");
			int tradingId = (Integer) map.get("tradingId");
			int orderId = orderIds.getInt(0);
			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCash(orderId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			YmatouEasyCall payPayMqSenderCall = new YmatouEasyCall("", "POST",
					"JSON");
			String payPayMqSenderString = "{\"orderId\":" + orderId + "}";
			payPayMqSenderCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/trading/onOrderPaid");
			payPayMqSenderCall.setData(payPayMqSenderString);
			Logger.comment("支付发送消息");
			payPayMqSenderCall.callService();
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);

			Thread.sleep(5000);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);

			verifyDb();

			// 查询交易退款结算表
			List<Map> settlementInvoiceList = new DefaultWapper()
					.selectYmtSettlementInvoice(orderId);

			// 结算佣金
			List<Map> ymtSettlemCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 4)
					.collect(Collectors.toList());
			// 返还佣金
			List<Map> ymtBackCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 6)
					.collect(Collectors.toList());

			BigDecimal settlemt1 = (BigDecimal) ymtSettlemCommissionDetailList
					.get(0).get("TotalAmount");

			BigDecimal settlemt2 = (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("TotalAmount");

			Logger.comment("校验Ymt_SettlementInvoice表，下单确认收货返佣结算");
			Logger.verifyEquals(
					String.valueOf(orderId),
					(String) ymtBackCommissionDetailList.get(0).get(
							"BusinessNo"), "验证BusinessNo");
			Logger.verifyEquals(orderId, (Integer) ymtBackCommissionDetailList
					.get(0).get("OrderId"), "验证OrderId");
			Logger.verifyEquals(settlemt1, settlemt2, "验证新买手,全部返回佣金");
			Logger.verifyEquals(
					((BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CashAmount"))
							.add((BigDecimal) ymtBackCommissionDetailList
									.get(0).get("CouponAmount")),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"TotalAmount"), "验证TotalAmount");
			Logger.verifyEquals(
					BigDecimal.ZERO.setScale(2),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CouponAmount"), "验证CouponAmount");
			Logger.verifyEquals(sellerId, (Integer) ymtBackCommissionDetailList
					.get(0).get("SellerId"), "验证SellerId");
			Logger.verifyEquals("返还交易服务费结算",
					(String) ymtBackCommissionDetailList.get(0).get("Remark"),
					"验证Remark");
			Logger.verifyEquals(0, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementStatus"), "验证SettlementStatus");
			Logger.verifyEquals(2, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementUser"), "验证SettlementUser");
			Logger.verifyEquals(
					null,
					(String) ymtBackCommissionDetailList.get(0).get(
							"ProcessResult"), "验证ProcessResult");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fAccountAmount"), "验证fAccountAmount");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fThirdPartyAmount"), "验证fThirdPartyAmount");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GenerateInvoicesOnOrderReceived_010() {
		Logger.start(true, "新客户，老买手，使用平台券,商家券。确认收货，不返还佣金");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			Map map = placeOrder6();
			int userId = (Integer) map.get("userId");
			int sellerId = (Integer) map.get("sellerId");
			JSONArray orderIds = (JSONArray) map.get("orderIds");
			int tradingId = (Integer) map.get("tradingId");
			int orderId = orderIds.getInt(0);
			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCash(orderId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			YmatouEasyCall payPayMqSenderCall = new YmatouEasyCall("", "POST",
					"JSON");
			String payPayMqSenderString = "{\"orderId\":" + orderId + "}";
			payPayMqSenderCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/trading/onOrderPaid");
			payPayMqSenderCall.setData(payPayMqSenderString);
			Logger.comment("支付发送消息");
			payPayMqSenderCall.callService();
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Thread.sleep(5000);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();

			// 查询交易退款结算表
			List<Map> settlementInvoiceList = new DefaultWapper()
					.selectYmtSettlementInvoice(orderId);

			// 结算佣金
			List<Map> ymtSettlemCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 4)
					.collect(Collectors.toList());
			// 返还佣金
			List<Map> ymtBackCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 6)
					.collect(Collectors.toList());

			BigDecimal settlemt1 = (BigDecimal) ymtSettlemCommissionDetailList
					.get(0).get("TotalAmount");

			BigDecimal settlemt2 = (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("TotalAmount");

			Logger.comment("校验Ymt_SettlementInvoice表，下单确认收货返佣结算");
			Logger.verifyEquals(
					String.valueOf(orderId),
					(String) ymtBackCommissionDetailList.get(0).get(
							"BusinessNo"), "验证BusinessNo");
			Logger.verifyEquals(orderId, (Integer) ymtBackCommissionDetailList
					.get(0).get("OrderId"), "验证OrderId");
			Logger.verifyEquals(BigDecimal.ZERO.setScale(2), settlemt2,
					"验证老买手，新客单，不返回佣金");
			Logger.verifyEquals(
					BigDecimal.ZERO.setScale(2),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"TotalAmount"), "验证TotalAmount");
			Logger.verifyEquals(
					BigDecimal.ZERO.setScale(2),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CouponAmount"), "验证CouponAmount");
			Logger.verifyEquals(sellerId, (Integer) ymtBackCommissionDetailList
					.get(0).get("SellerId"), "验证SellerId");
			Logger.verifyEquals("返还交易服务费结算",
					(String) ymtBackCommissionDetailList.get(0).get("Remark"),
					"验证Remark");
			Logger.verifyEquals(1, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementStatus"), "验证SettlementStatus");
			Logger.verifyEquals(2, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementUser"), "验证SettlementUser");
			Logger.verifyEquals(
					null,
					(String) ymtBackCommissionDetailList.get(0).get(
							"ProcessResult"), "验证ProcessResult");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fAccountAmount"), "验证fAccountAmount");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fThirdPartyAmount"), "验证fThirdPartyAmount");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GenerateInvoicesOnOrderReceived_011() {
		Logger.start(true, "有运费订单商品，使用平台券,商家券。确认收货，校验生成下单结算单，佣金结算单 2种结算单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService
					.placeOrder2(false);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);

			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

						Logger.verifyEquals("ok",
								generateinvoicesonorderreceivedCall.getReturnData(),
								"验证返回报文");*/

			verifyDb();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GenerateInvoicesOnOrderReceived_012() {
		Logger.start(true, "有运费订单商品,接单后一个商品部分退款,确认收货后,校验生成订单结算单佣金结算单");
		try {
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService
					.placeOrder2(false);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			// 部分退款
			BigDecimal partRefund = order.getOrderInfoList().get(0)
					.getProductPrice();

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJavaBean(orderId);

			applySalesRefundRequestBean.getSalesRefundInfoList().remove(1);
			applySalesRefundRequestBean.getSalesRefundInfoList().remove(1);

			applySalesRefundRequestBean.getSalesRefundInfoList().get(0)
					.setRefundAmount(partRefund);

			orderCallService
					.applySalesRefundRequestCall(applySalesRefundRequestBean);
			//退款执行
			orderCallService
					.salesrefundsuccessrequest(applySalesRefundRequestBean);

			// 确认收货
			orderCallService.confirmReceive(userId, orderId);

			Logger.comment("前置数据准备结束");

			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GenerateInvoicesOnOrderReceived_013() {
		Logger.start(true, "有运费订单商品,接单后一个商品退款加上退部分商品运费,确认收货后,校验生成订单结算单佣金结算单");
		try {
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService
					.placeOrder2(false);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 部分退款

			OrderInfoPo orderInfoPo1 = order.getOrderInfoList().get(0);

			BigDecimal partRefund = orderInfoPo1.getProductPrice()
					.multiply(new BigDecimal(orderInfoPo1.getAmount()))
					.add(orderInfoPo1.getFreight()).subtract(BigDecimal.ONE);

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJavaBean(orderId);

			applySalesRefundRequestBean.getSalesRefundInfoList().remove(1);
			applySalesRefundRequestBean.getSalesRefundInfoList().remove(1);

			applySalesRefundRequestBean.getSalesRefundInfoList().get(0)
					.setRefundAmount(partRefund);

			orderCallService
					.applySalesRefundRequestCall(applySalesRefundRequestBean);
			//退款执行
			orderCallService
					.salesrefundsuccessrequest(applySalesRefundRequestBean);

			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GenerateInvoicesOnOrderReceived_014() {
		Logger.start(true, "有运费订单商品,接单后一个商品退款加退运费超过商品运费,确认收货后,校验生成订单结算单佣金结算单");
		try {
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService
					.placeOrder2(false);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 部分退款

			OrderInfoPo orderInfoPo1 = order.getOrderInfoList().get(0);

			BigDecimal partRefund = orderInfoPo1.getProductPrice()
					.multiply(new BigDecimal(orderInfoPo1.getAmount()))
					.add(orderInfoPo1.getFreight()).add(BigDecimal.TEN);

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJavaBean(orderId);

			applySalesRefundRequestBean.getSalesRefundInfoList().remove(1);
			applySalesRefundRequestBean.getSalesRefundInfoList().remove(1);

			applySalesRefundRequestBean.getSalesRefundInfoList().get(0)
					.setRefundAmount(partRefund);

			orderCallService
					.applySalesRefundRequestCall(applySalesRefundRequestBean);
			//退款执行
			orderCallService
					.salesrefundsuccessrequest(applySalesRefundRequestBean);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);

			verifyDb();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GenerateInvoicesOnOrderReceived_015() {
		Logger.start(true, "有运费订单商品,接单后多个商品退款加退运费超过商品运费,确认收货后,校验生成订单结算单佣金结算单");
		try {
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService
					.placeOrder2(false);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			// 部分退款

			OrderInfoPo orderInfoPo1 = order.getOrderInfoList().get(0);
			OrderInfoPo orderInfoPo2 = order.getOrderInfoList().get(1);

			BigDecimal partRefund1 = calcRealPayAmountOnProduct(
					orderInfoPo1.getOrderInfoId()).add(BigDecimal.ONE);

			BigDecimal partRefund2 = calcRealPayAmountOnProduct(
					orderInfoPo2.getOrderInfoId()).add(BigDecimal.ONE);

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJavaBean(orderId);

			applySalesRefundRequestBean.getSalesRefundInfoList().remove(2);

			applySalesRefundRequestBean.getSalesRefundInfoList().get(0)
					.setRefundAmount(partRefund1);

			applySalesRefundRequestBean.getSalesRefundInfoList().get(1)
					.setRefundAmount(partRefund2);

			orderCallService
					.applySalesRefundRequestCall(applySalesRefundRequestBean);
			//退款执行
			orderCallService
					.salesrefundsuccessrequest(applySalesRefundRequestBean);

			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);

			verifyDb();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GenerateInvoicesOnOrderReceived_016() {
		Logger.start(true, "校验根据商品二级规格生成的广告费佣金，佣金结算单 2种结算单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService.placeOrder3(true);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);

			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);

			verifyDb();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	/**
	 * 下单使用补贴商品
	 */
	private Map placeOrder2() {
		Map map = new HashMap();
		PlaceOrderReq placeorderBean = new PlaceOrderReq();
		PlaceOrderCall placeorderCall = new PlaceOrderCall();
		try {
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			// 创建产品
			Logger.comment("前置数据准备");
			// 获取补贴商品信息
			HashMap<String, Object> productInfo = new DefaultWapper()
					.selectActivityProductSubsidy();
			int sellerId = (Integer) productInfo.get("SubsidyUserId");
			String productId = (String) productInfo.get("ProductId");
			String catalogId = (String) productInfo.get("CatalogId");
			BigDecimal productPrice = (BigDecimal) productInfo
					.get("ProductPrice");
			int activityId = (Integer) productInfo.get("ActivityId");

			Logger.comment("前置数据准备结束");
			placeorderBean.setAppId("AutoTest");
			// placeorderBean.setYmatouCoupon(ymtCoupon);
			placeorderBean.setUserId(userId);
			placeorderBean.setRequestId(TestDataManager.getRandomUUID()
					.toString());
			placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
			placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
			placeorderBean.setSourceIp("127.0.0.1");
			placeorderBean.setAppId("ios");
			placeorderBean.setDeviceId("7777777777888888888888999");
			OrderGroupVo groupVo1 = new OrderGroupVo();
			placeorderBean.setOrderSource(OrderSourceEnum.PC);
			// groupVo1.setSellerCoupon(sellerCoupon);
			groupVo1.setSellerId(sellerId);
			List<OrderVo> orders = new ArrayList<OrderVo>();
			OrderVo ordervo1 = new OrderVo();
			ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
			ordervo1.setOrderType(OrderTypeEnum.Spot);
			ordervo1.setPaidFull(true);
			ordervo1.setAddress("上海市闸北区灵石路636号");
			ordervo1.setLeaveWord("ymt autotest");
			ordervo1.setPhone("13100000001");
			ordervo1.setPostCode("200001");
			ordervo1.setTelephone("021-51002100");
			ordervo1.setReceiveName("李四");
			List<OrderItemVo> items = new ArrayList<OrderItemVo>();
			OrderItemVo orderitem1 = new OrderItemVo();
			orderitem1.setCatalogId(catalogId);
			orderitem1.setProductNum(1);
			orderitem1.setProductName("autotest补贴商品测试");
			orderitem1.setPriceType(PriceTypeEnum.VipPrice);
			orderitem1.setProductId(productId);

			// price = new BigDecimal(210);
			orderitem1.setEarnestPrice(productPrice);
			orderitem1.setProductPrice(productPrice);
			orderitem1.setOriginalPrice(productPrice);
			orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1.setBrandId(5);
			orderitem1.setPackageNo("11111111");
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(22222);
			orderitem1.setThirdCategoryId(33333);
			orderitem1
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem1.setProductRecordNo("1234567");
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			ActivityVo activity = new ActivityVo();
			activity.setActivityId(activityId);
			activity.setActivityBeginDate(YMTDateUtil.getBeforeOrNextDay(-10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityEndDate(YMTDateUtil.getBeforeOrNextDay(10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityTemplateId(12345678);
			activity.setCommissionRate(new BigDecimal(1.1));
			activity.setCost(true);
			activity.setFeeFree(false);
			activity.setPremium(new BigDecimal(1.5));
			activity.setPromotionPrice(new BigDecimal(15));
			activity.setPromotionType(ActivityPromotionTypeEnum.DiscountRate);
			activity.setUseCoupon(true);
			orderitem1.setActivity(activity);
			items.add(orderitem1);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			orders.add(ordervo1);
			groupVo1.setOrders(orders);
			placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
			placeorderCall.setData(false, placeorderBean);
			placeorderCall.callService();

			int tradingId = placeorderCall.getTradingId();
			int orderId = placeorderCall.getOrderIds().getInt(0);
			map.put("orderId", orderId);
			map.put("tradingId", tradingId);
			map.put("sellerId", sellerId);
		} catch (Exception e) {
			Logger.fail(e);
		}
		return map;

	}

	/**
	 * 一个订单下面多个商品, 60天注册新买手，老客户
	 */
	private Map placeOrder3() {

		Map map = new HashMap();

		try {
			PlaceOrderReq placeorderBean = new PlaceOrderReq();
			PlaceOrderCall placeorderCall = new PlaceOrderCall();
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			// 审核在90天内的新买手
			sellerId = 20224977;
			// 创建产品
			Logger.comment("前置数据准备");
			HashMap<String, Object> productInfo = ProductCallService
					.createProduct(sellerId, 3);
			Logger.comment("前置数据准备结束");
			String productId = (String) productInfo.get("productId");
			Logger.debug("productId:" + productId);
			String productName = (String) productInfo.get("productName");
			String pic = (String) productInfo.get("pic");
			BigDecimal price = (BigDecimal) (productInfo.get("price"));
			String catalogId = (String) productInfo.get("catalogId");
			YmatouCouponVo ymtCoupon = new YmatouCouponVo();

			// 平台优惠券
			BigDecimal couponValue = new BigDecimal(13);

			String couponCode = new OrderCallService().receivePlatformCoupon(
					userId, couponValue);

			ymtCoupon.setApplianceType(YmatouCouponApplianceTypeEnum.ALL);
			ymtCoupon.setCouponCode(couponCode);
			ymtCoupon.setCouponValue(couponValue);
			placeorderBean.setAppId("AutoTest");
			placeorderBean.setYmatouCoupon(ymtCoupon);
			placeorderBean.setUserId(userId);
			placeorderBean.setRequestId(TestDataManager.getRandomUUID()
					.toString());
			placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
			placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
			placeorderBean.setSourceIp("127.0.0.1");
			placeorderBean.setAppId("ios");
			placeorderBean.setDeviceId("7777777777888888888888999");
			OrderGroupVo groupVo1 = new OrderGroupVo();
			placeorderBean.setOrderSource(OrderSourceEnum.PC);
			// 商家优惠券
			BigDecimal sellerCouponValue = new BigDecimal(15);
			String sellerCouponCode = new CouponCallService()
					.receiveCouponInfo(sellerId, userId, couponValue);
			SellerCouponVo sellerCoupon = new SellerCouponVo();
			sellerCoupon.setApplianceType(SellerCouponApplianceTypeEnum.ALL);
			sellerCoupon.setCouponCode(sellerCouponCode);
			sellerCoupon.setCouponValue(sellerCouponValue);
			groupVo1.setSellerCoupon(sellerCoupon);
			groupVo1.setSellerId(sellerId);
			List<OrderVo> orders = new ArrayList<OrderVo>();
			OrderVo ordervo1 = new OrderVo();
			ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
			ordervo1.setOrderType(OrderTypeEnum.Spot);
			ordervo1.setPaidFull(true);
			ordervo1.setAddress("上海市闸北区灵石路636号");
			ordervo1.setLeaveWord("ymt autotest");
			ordervo1.setPhone("13100000001");
			ordervo1.setPostCode("200001");
			ordervo1.setTelephone("021-51002100");
			ordervo1.setReceiveName("李四");
			List<OrderItemVo> items = new ArrayList<OrderItemVo>();
			OrderItemVo orderitem1 = new OrderItemVo();
			orderitem1.setCatalogId(TestDataManager.getRandomUUID().toString());
			orderitem1.setProductNum(3);
			orderitem1.setProductName(productName);
			orderitem1.setPriceType(PriceTypeEnum.VipPrice);
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(2);
			orderitem1.setThirdCategoryId(3);
			orderitem1.setProductId(TestDataManager.getRandomUUID().toString());

			price = new BigDecimal(21);
			orderitem1.setEarnestPrice(price);
			orderitem1.setProductPrice(price);
			orderitem1.setOriginalPrice(price);
			orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1.setBrandId(5);
			orderitem1.setPackageNo("11111111");
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(22222);
			orderitem1.setThirdCategoryId(33333);
			orderitem1
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem1.setProductRecordNo("1234567");
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			ActivityVo activity = new ActivityVo();
			activity.setActivityId(46870);
			activity.setActivityBeginDate(YMTDateUtil.getBeforeOrNextDay(-10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityEndDate(YMTDateUtil.getBeforeOrNextDay(10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityTemplateId(12345678);
			activity.setCommissionRate(new BigDecimal(1.1));
			activity.setCost(true);
			activity.setFeeFree(false);
			activity.setPremium(new BigDecimal(1.5));
			activity.setPromotionPrice(new BigDecimal(15));
			activity.setPromotionType(ActivityPromotionTypeEnum.DiscountRate);
			activity.setUseCoupon(true);
			orderitem1.setActivity(activity);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			// 第2件商品
			OrderItemVo orderitem2 = new OrderItemVo();
			orderitem2.setCatalogId("edbcc2c9-1ba9-4b04-ab88-940f63271823");
			orderitem2.setProductNum(1);
			orderitem2.setProductName(productName);
			orderitem2.setPriceType(PriceTypeEnum.VipPrice);
			orderitem2.setProductId(TestDataManager.getRandomUUID().toString());
			orderitem2.setFirstCategoryId(1149);
			orderitem2.setSecondCategoryId(2);
			orderitem2.setThirdCategoryId(3);
			price = new BigDecimal(30000);
			orderitem2.setEarnestPrice(price);
			orderitem2.setProductPrice(price);
			orderitem2.setOriginalPrice(price);
			orderitem2.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem2.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2.setBrandId(5);
			orderitem2.setPackageNo("11111111");
			orderitem2
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem2.setProductRecordNo("1234567");
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			orderitem2.setActivity(activity);
			items.add(orderitem1);
			items.add(orderitem2);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			orders.add(ordervo1);
			groupVo1.setOrders(orders);
			placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
			placeorderCall.setData(false, placeorderBean);
			placeorderCall.callService();
			JSONArray orderIds = placeorderCall.getOrderIds();
			int tradingId = placeorderCall.getTradingId();
			map.put("userId", userId);
			map.put("sellerId", sellerId);
			map.put("orderIds", orderIds);
			map.put("tradingId", tradingId);
		} catch (Exception e) {
			Logger.fail(e);
		}
		return map;
	}

	/**
	 * 一个订单下面多个商品, 老买手，老客单 买家在买手 店铺支付完成的第
	 * 
	 * 一单所在日期之后的其他订单（同一买家在该买手店铺支付完成的订单）为该买手的老客订单
	 */
	private PlaceOrderResp placeOrder4() {
		PlaceOrderResp resp = new PlaceOrderResp();
		try {

			//注册新用户
			int userId = new OrderCallService().createNewUser();

			Map user = new HashMap<>();

			user.put("userId", userId);

			// sellerId = 20224977;
			Map firstOrder = new OrderCallService().createM2cOrder(user);

			int orderId = (Integer) firstOrder.get("orderId");
			int tradingId = (Integer) firstOrder.get("tradingId");

			BigDecimal totalPrice = (BigDecimal) firstOrder.get("totalPrice");// 支付金额

			// 支付
			new OrderCallService().orderPayRequest(userId, totalPrice,
					tradingId);
			// 更新订单支付时间
			new DefaultWapper().updateOrderPaidTimeByOrderId(orderId);

			PlaceOrderReq placeorderBean = PlaceOrderService
					.getDefaultOrderReq(userId);

			placeorderBean.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems()
					.add(PlaceOrderService.getDefaultOrderItemVo());

			placeorderBean.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems()
					.forEach(item -> item.setFirstCategoryId(1149));

			resp = PlaceOrderService.callPlaceOrderService(placeorderBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
		return resp;
	}
	/**
	 * 一个订单下面多个商品, 新买手，老客单
	 * 
	 * 一单所在日期之后的其他订单（同一买家在该买手店铺支付完成的订单）为该买手的老客订单
	 */
	private Map placeOrder5() {
		Map map = new HashMap();
		try {
			PlaceOrderReq placeorderBean = new PlaceOrderReq();
			PlaceOrderCall placeorderCall = new PlaceOrderCall();
			// 注册新用户
			Map newUser = new HashMap();
			newUser = new UserCallService().registerByMobile();

			int userId = (Integer) newUser.get("userid");
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));

			// 审核在60天内的新买手
			sellerId = 20224977;
			Map firstOrder = new HashMap();
			firstOrder = new OrderCallService().createM2cOrder(newUser);
			int orderId = (Integer) firstOrder.get("orderId");
			int tradingId = (Integer) firstOrder.get("tradingId");
			BigDecimal totalPrice = (BigDecimal) firstOrder.get("totalPrice");// 支付金额
			// 支付
			new OrderCallService().orderPayRequest(userId, totalPrice,
					tradingId);
			// 更新订单支付时间
			new DefaultWapper().updateOrderPaidTimeByOrderId(orderId);
			// 创建产品
			Logger.comment("前置数据准备");
			HashMap<String, Object> productInfo = ProductCallService
					.createProduct(sellerId, 3);
			Logger.comment("前置数据准备结束");
			String productId = (String) productInfo.get("productId");
			Logger.debug("productId:" + productId);
			String productName = (String) productInfo.get("productName");
			String pic = (String) productInfo.get("pic");
			BigDecimal price = (BigDecimal) (productInfo.get("price"));
			String catalogId = (String) productInfo.get("catalogId");
			YmatouCouponVo ymtCoupon = new YmatouCouponVo();
			// 平台优惠券
			BigDecimal couponValue = new BigDecimal(13);
			String couponCode = new OrderCallService().receivePlatformCoupon(
					userId, couponValue);
			ymtCoupon.setApplianceType(YmatouCouponApplianceTypeEnum.ALL);
			ymtCoupon.setCouponCode(couponCode);
			ymtCoupon.setCouponValue(couponValue);
			placeorderBean.setAppId("AutoTest");
			placeorderBean.setYmatouCoupon(ymtCoupon);
			placeorderBean.setUserId(userId);
			placeorderBean.setRequestId(TestDataManager.getRandomUUID()
					.toString());
			placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
			placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
			placeorderBean.setSourceIp("127.0.0.1");
			placeorderBean.setAppId("ios");
			placeorderBean.setDeviceId("7777777777888888888888999");
			OrderGroupVo groupVo1 = new OrderGroupVo();
			placeorderBean.setOrderSource(OrderSourceEnum.PC);
			// 商家优惠券
			BigDecimal sellerCouponValue = new BigDecimal(15);
			String sellerCouponCode = new CouponCallService()
					.receiveCouponInfo(sellerId, userId, couponValue);
			SellerCouponVo sellerCoupon = new SellerCouponVo();
			sellerCoupon.setApplianceType(SellerCouponApplianceTypeEnum.ALL);
			sellerCoupon.setCouponCode(sellerCouponCode);
			sellerCoupon.setCouponValue(sellerCouponValue);
			groupVo1.setSellerCoupon(sellerCoupon);
			groupVo1.setSellerId(sellerId);
			List<OrderVo> orders = new ArrayList<OrderVo>();
			OrderVo ordervo1 = new OrderVo();
			ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
			ordervo1.setOrderType(OrderTypeEnum.Spot);
			ordervo1.setPaidFull(true);
			ordervo1.setAddress("上海市闸北区灵石路636号");
			ordervo1.setLeaveWord("ymt autotest");
			ordervo1.setPhone("13100000001");
			ordervo1.setPostCode("200001");
			ordervo1.setTelephone("021-51002100");
			ordervo1.setReceiveName("李四");
			List<OrderItemVo> items = new ArrayList<OrderItemVo>();
			OrderItemVo orderitem1 = new OrderItemVo();
			orderitem1.setCatalogId(TestDataManager.getRandomUUID().toString());
			orderitem1.setProductNum(3);
			orderitem1.setProductName(productName);
			orderitem1.setPriceType(PriceTypeEnum.VipPrice);
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setProductId(TestDataManager.getRandomUUID().toString());
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(22222);
			orderitem1.setThirdCategoryId(33333);
			price = new BigDecimal(21);
			orderitem1.setEarnestPrice(price);
			orderitem1.setProductPrice(price);
			orderitem1.setOriginalPrice(price);
			orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1.setBrandId(5);
			orderitem1.setPackageNo("11111111");
			orderitem1
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem1.setProductRecordNo("1234567");
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			ActivityVo activity = new ActivityVo();
			activity.setActivityId(46870);
			activity.setActivityBeginDate(YMTDateUtil.getBeforeOrNextDay(-10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityEndDate(YMTDateUtil.getBeforeOrNextDay(10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityTemplateId(12345678);
			activity.setCommissionRate(new BigDecimal(1.1));
			activity.setCost(true);
			activity.setFeeFree(false);
			activity.setPremium(new BigDecimal(1.5));
			activity.setPromotionPrice(new BigDecimal(15));
			activity.setPromotionType(ActivityPromotionTypeEnum.DiscountRate);
			activity.setUseCoupon(true);
			orderitem1.setActivity(activity);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			// 第2件商品
			OrderItemVo orderitem2 = new OrderItemVo();
			orderitem2.setCatalogId("edbcc2c9-1ba9-4b04-ab88-940f63271823");
			orderitem2.setProductNum(1);
			orderitem2.setProductName(productName);
			orderitem2.setPriceType(PriceTypeEnum.VipPrice);
			orderitem2.setProductId(TestDataManager.getRandomUUID().toString());
			orderitem2.setFirstCategoryId(1149);
			price = new BigDecimal(30);
			orderitem2.setEarnestPrice(price);
			orderitem2.setProductPrice(price);
			orderitem2.setOriginalPrice(price);
			orderitem2.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem2.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2.setBrandId(5);
			orderitem2.setPackageNo("11111111");
			orderitem2
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem2.setProductRecordNo("1234567");
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			orderitem2.setActivity(activity);
			items.add(orderitem1);
			items.add(orderitem2);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			orders.add(ordervo1);
			groupVo1.setOrders(orders);
			placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
			placeorderCall.setData(false, placeorderBean);
			placeorderCall.callService();
			JSONArray orderIds = placeorderCall.getOrderIds();
			int tradingId2 = placeorderCall.getTradingId();
			map.put("userId", userId);
			map.put("sellerId", sellerId);
			map.put("orderIds", orderIds);
			map.put("tradingId", tradingId2);
		} catch (Exception e) {
			Logger.fail(e);
		}
		return map;
	}

	/**
	 * 一个订单下面多个商品, 老买手，新用户
	 * 
	 * 一单所在日期之后的其他订单（同一买家在该买手店铺支付完成的订单）为该买手的老客订单
	 */
	private Map placeOrder6() {
		Map map = new HashMap();
		try {
			PlaceOrderReq placeorderBean = new PlaceOrderReq();
			PlaceOrderCall placeorderCall = new PlaceOrderCall();
			// 注册新用户
			Map newUser = new HashMap();
			newUser = new OrderCallService().registerUser();

			int userId = (Integer) newUser.get("userId");
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			// 创建产品
			Logger.comment("前置数据准备");
			HashMap<String, Object> productInfo = ProductCallService
					.createProduct(sellerId, 3);
			Logger.comment("前置数据准备结束");
			String productId = (String) productInfo.get("productId");
			Logger.debug("productId:" + productId);
			String productName = (String) productInfo.get("productName");
			String pic = (String) productInfo.get("pic");
			BigDecimal price = (BigDecimal) (productInfo.get("price"));
			String catalogId = (String) productInfo.get("catalogId");
			YmatouCouponVo ymtCoupon = new YmatouCouponVo();
			// 平台优惠券
			BigDecimal couponValue = new BigDecimal(13);
			String couponCode = new OrderCallService().receivePlatformCoupon(
					userId, couponValue);
			ymtCoupon.setApplianceType(YmatouCouponApplianceTypeEnum.ALL);
			ymtCoupon.setCouponCode(couponCode);
			ymtCoupon.setCouponValue(couponValue);
			placeorderBean.setAppId("AutoTest");
			placeorderBean.setYmatouCoupon(ymtCoupon);
			placeorderBean.setUserId(userId);
			placeorderBean.setRequestId(TestDataManager.getRandomUUID()
					.toString());
			placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
			placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
			placeorderBean.setSourceIp("127.0.0.1");
			placeorderBean.setAppId("ios");
			placeorderBean.setDeviceId("7777777777888888888888999");
			OrderGroupVo groupVo1 = new OrderGroupVo();
			placeorderBean.setOrderSource(OrderSourceEnum.PC);
			// 商家优惠券
			BigDecimal sellerCouponValue = new BigDecimal(15);
			String sellerCouponCode = new CouponCallService()
					.receiveCouponInfo(sellerId, userId, couponValue);
			SellerCouponVo sellerCoupon = new SellerCouponVo();
			sellerCoupon.setApplianceType(SellerCouponApplianceTypeEnum.ALL);
			sellerCoupon.setCouponCode(sellerCouponCode);
			sellerCoupon.setCouponValue(sellerCouponValue);
			groupVo1.setSellerCoupon(sellerCoupon);
			groupVo1.setSellerId(sellerId);
			List<OrderVo> orders = new ArrayList<OrderVo>();
			OrderVo ordervo1 = new OrderVo();
			ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
			ordervo1.setOrderType(OrderTypeEnum.Spot);
			ordervo1.setPaidFull(true);
			ordervo1.setAddress("上海市闸北区灵石路636号");
			ordervo1.setLeaveWord("ymt autotest");
			ordervo1.setPhone("13100000001");
			ordervo1.setPostCode("200001");
			ordervo1.setTelephone("021-51002100");
			ordervo1.setReceiveName("李四");
			List<OrderItemVo> items = new ArrayList<OrderItemVo>();
			OrderItemVo orderitem1 = new OrderItemVo();
			orderitem1.setCatalogId(TestDataManager.getRandomUUID().toString());
			orderitem1.setProductNum(3);
			orderitem1.setProductName(productName);
			orderitem1.setPriceType(PriceTypeEnum.VipPrice);
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(2);
			orderitem1.setThirdCategoryId(3);
			orderitem1.setProductId(TestDataManager.getRandomUUID().toString());
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(22222);
			orderitem1.setThirdCategoryId(33333);
			price = new BigDecimal(21);
			orderitem1.setEarnestPrice(price);
			orderitem1.setProductPrice(price);
			orderitem1.setOriginalPrice(price);
			orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1.setBrandId(5);
			orderitem1.setPackageNo("11111111");
			orderitem1
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem1.setProductRecordNo("1234567");
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			ActivityVo activity = new ActivityVo();
			activity.setActivityId(46870);
			activity.setActivityBeginDate(YMTDateUtil.getBeforeOrNextDay(-10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityEndDate(YMTDateUtil.getBeforeOrNextDay(10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityTemplateId(12345678);
			activity.setCommissionRate(new BigDecimal(1.1));
			activity.setCost(true);
			activity.setFeeFree(false);
			activity.setPremium(new BigDecimal(1.5));
			activity.setPromotionPrice(new BigDecimal(15));
			activity.setPromotionType(ActivityPromotionTypeEnum.DiscountRate);
			activity.setUseCoupon(true);
			orderitem1.setActivity(activity);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			// 第2件商品
			OrderItemVo orderitem2 = new OrderItemVo();
			orderitem2.setCatalogId("edbcc2c9-1ba9-4b04-ab88-940f63271823");
			orderitem2.setProductNum(1);
			orderitem2.setProductName(productName);
			orderitem2.setPriceType(PriceTypeEnum.VipPrice);
			orderitem2.setProductId(TestDataManager.getRandomUUID().toString());
			orderitem2.setFirstCategoryId(1149);
			orderitem2.setSecondCategoryId(2);
			orderitem2.setThirdCategoryId(3);
			price = new BigDecimal(30);
			orderitem2.setEarnestPrice(price);
			orderitem2.setProductPrice(price);
			orderitem2.setOriginalPrice(price);
			orderitem2.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem2.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2.setBrandId(5);
			orderitem2.setPackageNo("11111111");
			orderitem2.setFirstCategoryId(1149);
			orderitem2.setSecondCategoryId(22222);
			orderitem2.setThirdCategoryId(33333);
			orderitem2
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem2.setProductRecordNo("1234567");
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			orderitem2.setActivity(activity);
			items.add(orderitem1);
			items.add(orderitem2);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			orders.add(ordervo1);
			groupVo1.setOrders(orders);
			placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
			placeorderCall.setData(false, placeorderBean);
			placeorderCall.callService();
			JSONArray orderIds = placeorderCall.getOrderIds();
			int tradingId2 = placeorderCall.getTradingId();
			map.put("userId", userId);
			map.put("sellerId", sellerId);
			map.put("orderIds", orderIds);
			map.put("tradingId", tradingId2);
		} catch (Exception e) {
			Logger.fail(e);
		}
		return map;
	}
	/**
	 * 一个订单下面多个商品, 新买手，新用户
	 * 
	 * 一单所在日期之后的其他订单（同一买家在该买手店铺支付完成的订单）为该买手的老客订单
	 */
	private Map placeOrder7() {

		Map map = new HashMap();

		try {
			PlaceOrderReq placeorderBean = new PlaceOrderReq();
			PlaceOrderCall placeorderCall = new PlaceOrderCall();
			// 注册新用户
			Map newUser = new HashMap();
			newUser = new OrderCallService().registerUser();

			int userId = (Integer) newUser.get("userId");
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));

			// 审核在90天内的新买手
			sellerId = 20224977;
			Map firstOrder = new HashMap();
			firstOrder = new OrderCallService().createM2cOrder(newUser);
			int orderId = (Integer) firstOrder.get("orderId");
			int tradingId = (Integer) firstOrder.get("tradingId");
			BigDecimal totalPrice = (BigDecimal) firstOrder.get("totalPrice");// 支付金额
			// 创建产品
			Logger.comment("前置数据准备");
			HashMap<String, Object> productInfo = ProductCallService
					.createProduct(sellerId, 3);
			Logger.comment("前置数据准备结束");
			String productId = (String) productInfo.get("productId");
			Logger.debug("productId:" + productId);
			String productName = (String) productInfo.get("productName");
			String pic = (String) productInfo.get("pic");
			BigDecimal price = (BigDecimal) (productInfo.get("price"));
			String catalogId = (String) productInfo.get("catalogId");
			YmatouCouponVo ymtCoupon = new YmatouCouponVo();
			// 平台优惠券
			BigDecimal couponValue = new BigDecimal(13);
			String couponCode = new OrderCallService().receivePlatformCoupon(
					userId, couponValue);
			ymtCoupon.setApplianceType(YmatouCouponApplianceTypeEnum.ALL);
			ymtCoupon.setCouponCode(couponCode);
			ymtCoupon.setCouponValue(couponValue);
			placeorderBean.setAppId("AutoTest");
			placeorderBean.setYmatouCoupon(ymtCoupon);
			placeorderBean.setUserId(userId);
			placeorderBean.setRequestId(TestDataManager.getRandomUUID()
					.toString());
			placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
			placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
			placeorderBean.setSourceIp("127.0.0.1");
			placeorderBean.setAppId("ios");
			placeorderBean.setDeviceId("7777777777888888888888999");
			OrderGroupVo groupVo1 = new OrderGroupVo();
			placeorderBean.setOrderSource(OrderSourceEnum.PC);
			// 商家优惠券
			BigDecimal sellerCouponValue = new BigDecimal(15);
			String sellerCouponCode = new CouponCallService()
					.receiveCouponInfo(sellerId, userId, couponValue);
			SellerCouponVo sellerCoupon = new SellerCouponVo();
			sellerCoupon.setApplianceType(SellerCouponApplianceTypeEnum.ALL);
			sellerCoupon.setCouponCode(sellerCouponCode);
			sellerCoupon.setCouponValue(sellerCouponValue);
			groupVo1.setSellerCoupon(sellerCoupon);
			groupVo1.setSellerId(sellerId);
			List<OrderVo> orders = new ArrayList<OrderVo>();
			OrderVo ordervo1 = new OrderVo();
			ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
			ordervo1.setOrderType(OrderTypeEnum.Spot);
			ordervo1.setPaidFull(true);
			ordervo1.setAddress("上海市闸北区灵石路636号");
			ordervo1.setLeaveWord("ymt autotest");
			ordervo1.setPhone("13100000001");
			ordervo1.setPostCode("200001");
			ordervo1.setTelephone("021-51002100");
			ordervo1.setReceiveName("李四");
			List<OrderItemVo> items = new ArrayList<OrderItemVo>();
			OrderItemVo orderitem1 = new OrderItemVo();
			orderitem1.setCatalogId(TestDataManager.getRandomUUID().toString());
			orderitem1.setProductNum(3);
			orderitem1.setProductName(productName);
			orderitem1.setPriceType(PriceTypeEnum.VipPrice);
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(2);
			orderitem1.setThirdCategoryId(3);
			orderitem1.setProductId(TestDataManager.getRandomUUID().toString());

			price = new BigDecimal(21);
			orderitem1.setEarnestPrice(price);
			orderitem1.setProductPrice(price);
			orderitem1.setOriginalPrice(price);
			orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1.setBrandId(5);
			orderitem1.setPackageNo("11111111");
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(22222);
			orderitem1.setThirdCategoryId(33333);
			orderitem1
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem1.setProductRecordNo("1234567");
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			ActivityVo activity = new ActivityVo();
			activity.setActivityId(46870);
			activity.setActivityBeginDate(YMTDateUtil.getBeforeOrNextDay(-10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityEndDate(YMTDateUtil.getBeforeOrNextDay(10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityTemplateId(12345678);
			activity.setCommissionRate(new BigDecimal(1.1));
			activity.setCost(true);
			activity.setFeeFree(false);
			activity.setPremium(new BigDecimal(1.5));
			activity.setPromotionPrice(new BigDecimal(15));
			activity.setPromotionType(ActivityPromotionTypeEnum.DiscountRate);
			activity.setUseCoupon(true);
			orderitem1.setActivity(activity);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			// 第2件商品
			OrderItemVo orderitem2 = new OrderItemVo();
			orderitem2.setCatalogId("edbcc2c9-1ba9-4b04-ab88-940f63271823");
			orderitem2.setProductNum(1);
			orderitem2.setProductName(productName);
			orderitem2.setPriceType(PriceTypeEnum.VipPrice);
			orderitem2.setProductId(TestDataManager.getRandomUUID().toString());
			orderitem2.setFirstCategoryId(1149);
			orderitem2.setSecondCategoryId(2);
			orderitem2.setThirdCategoryId(3);

			price = new BigDecimal(30);
			orderitem2.setEarnestPrice(price);
			orderitem2.setProductPrice(price);
			orderitem2.setOriginalPrice(price);
			orderitem2.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem2.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2.setBrandId(5);
			orderitem2.setPackageNo("11111111");
			orderitem2
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem2.setProductRecordNo("1234567");
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			orderitem2.setActivity(activity);
			items.add(orderitem1);
			items.add(orderitem2);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			orders.add(ordervo1);
			groupVo1.setOrders(orders);
			placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
			placeorderCall.setData(false, placeorderBean);
			placeorderCall.callService();
			JSONArray orderIds = placeorderCall.getOrderIds();
			int tradingId2 = placeorderCall.getTradingId();
			map.put("userId", userId);
			map.put("sellerId", sellerId);
			map.put("orderIds", orderIds);
			map.put("tradingId", tradingId2);
		} catch (Exception e) {
			Logger.fail(e);
		}
		return map;
	}
}
